# encoding: utf-8
#
# Redmine - project management software
# Copyright (C) 2006-2012  Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

require_dependency 'repositories_helper'

# add <redmine_plaistc>/init.rb 
# require_dependency 'repositories_helper_patch'

# Patches Redmine's RepositoriesHelper dynamically.
# Adds plastic_field_tags methods
module RepositoriesHelperPatch
  def self.included(base) # :nodoc:
    base.send(:include, InstanceMethods)
  end
  
  module InstanceMethods
    
    def plastic_field_tags(form, repository)
      content_tag('p', form.text_field(
                         :url,
                         :label => l(:field_plastic_repository_server).html_safe,
                         :size => 60, :required => true,
                         :disabled => !repository.safe_attribute?('url'),
                         ) +
                       '<br />'.html_safe + l(:text_plastic_repository_server_note).html_safe) +
      content_tag('p', form.text_field(
                         :extra_selected_branch,
                         :label => l(:field_plastic_selected_branch).html_safe,
                         :size => 60, :required => true,
                         ) +
                       '<br />'.html_safe + l(:text_plastic_selected_branch_note).html_safe) +
      content_tag('p', form.text_field(
                         :extra_additional_branches,
                         :label => l(:field_plastic_additional_branches).html_safe,
                         :size => 60,
                         ) +
                       '<br />'.html_safe + l(:text_plastic_additional_branches_note).html_safe) +
      content_tag('p', form.check_box(
                         :extra_use_additional_branches,
                         :label => l(:label_plastic_use_additional_branches).html_safe
                         ) +
                       '<br />'.html_safe + l(:text_plastic_use_additional_branches_note).html_safe) +                       
      content_tag('p', form.text_field(
                         :root_url,
                         :label => l(:field_plastic_path_to_workspace).html_safe,
                         :size => 80,
                         :disabled => true # not yet supported
                         ) +
                       '<br />'.html_safe + l(:text_plastic_path_to_workspace_note).html_safe)
    end
  end
end

# Add module to RepositoriesHelper
RepositoriesHelper.send(:include, RepositoriesHelperPatch)